package com.ruoyi.project.order.controller;


import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.project.order.domain.HisOrderCharge;
import com.ruoyi.project.order.domain.HisOrderChargeItem;
import com.ruoyi.project.order.service.HisOrderChargeItemService;
import com.ruoyi.project.order.service.HisOrderChargeService;
import com.ruoyi.project.system.domain.SysPost;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

import static com.github.pagehelper.page.PageMethod.startPage;

@RestController
@RequestMapping("/order/commit")
public class HisOrderChargeController extends BaseController {

    @Autowired
    private HisOrderChargeService orderChargeService;

    @Autowired
    private HisOrderChargeItemService chargeItemService;


    @PreAuthorize("@ss.hasPermi('order:commit:list')")
    @GetMapping("/list")
    public TableDataInfo list(HisOrderCharge orderCharge) {
        startPage();
        List<HisOrderCharge> hisOrderCharges = orderChargeService.selectOrderChargeList(orderCharge);
        return getDataTable(hisOrderCharges);
    }

    @GetMapping("/{orderId}")
    public AjaxResult getItem(@PathVariable String orderId){
        List<HisOrderChargeItem> orderChargeItemList = chargeItemService.selectListById(orderId);
        return AjaxResult.success(orderChargeItemList);
    }
}
